package view

import (
	"context"
	"miao-wails/backed/app/service"
	"miao-wails/backed/lib/utils"
	"miao-wails/backed/structs/base"
	"miao-wails/backed/structs/tables"
)

type SecretText struct {
	ctx context.Context
}

func NewSecretText() *SecretText {
	return &SecretText{}
}

func (a SecretText) AddSecretKey(in base.AddSecretKey) (err error) {
	return service.SecTextSer.AddSecretKey(in)
}
func (a SecretText) GetSecretKeyList() (li []tables.SecretKey, err error) {
	return service.SecTextSer.GetSecretKeyList()
}
func (a SecretText) DelSecretKey(kid string) (err error) {
	return service.SecTextSer.DelSecretKey(utils.StrToInt64(kid))
}
func (a SecretText) AddText(in base.AddSecretText) (err error) {
	return service.SecTextSer.AddText(in)
}
func (a SecretText) GetTextList(isPrivate bool) (li []tables.SecretText, err error) {
	return service.SecTextSer.GetTextList(isPrivate)
}
func (a SecretText) DelText(id int64, adminKey string) (err error) {
	return service.SecTextSer.DelText(id, adminKey)
}
func (a SecretText) UpdateText(in base.UpdateSecretText) (err error) {
	return service.SecTextSer.UpdateText(in)
}

func (a SecretText) GetTextContent(tid string, adminKey string) (textDetail base.SecretTextContent, err error) {
	return service.SecTextSer.GetTextContent(utils.StrToInt64(tid), adminKey)
}

func (a SecretText) UpdateTextContent(tid string, conStr string) (err error) {
	return service.SecTextSer.UpdateTextContent(utils.StrToInt64(tid), conStr)
}

func (a SecretText) AddChapter(tid string, title string, conStr string) (err error) {
	return service.SecTextSer.AddChapter(utils.StrToInt64(tid), title, conStr)
}

func (a SecretText) DelChapter(tid string, cid string, adminKey string) (err error) {
	return service.SecTextSer.DelChapter(utils.StrToInt64(tid), utils.StrToInt64(cid), adminKey)
}
